package com.example.rediscache.mapper;


import com.example.rediscache.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 根据用户 id 查询用户信息
     */
    @Cacheable(cacheNames = "redisCache:#30", key = "'redis_user_'+#userId")
    UserInfo getUserById(@Param("userId") Integer userId);

    /**
     * 查询全部
     */
    List<UserInfo> getAll();

    /**
     * 添加用户对象
     */
    int add(UserInfo UserInfo);

}
